package com.avcdata;


import com.alibaba.fastjson.JSONObject;

import java.sql.*;
import java.util.List;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws SQLException {
        try {
            String driverName = "org.apache.hive.jdbc.HiveDriver";
            Class.forName(driverName);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        Connection conn = DriverManager.getConnection("jdbc:hive2://node2:10000", "root", "");
        Statement stmt = conn.createStatement();
        String sql = "SELECT * FROM psn7";
        ResultSet rs = stmt.executeQuery(sql);


        while (rs.next()) {
            List<String> likes = JSONObject.parseArray(rs.getString(3), String.class);
            Map address = JSONObject.parseObject(rs.getString(4), Map.class);
            System.out.println(rs.getString(1) + "\t" + rs.getString(2));
            System.out.println(likes);
            System.out.println(address);
        }
    }
}
